package com.xzit.homework;

import java.util.Map;

public class GradeManager {
    private Map<String, Integer> grades;
    public void setGrades(Map<String, Integer> grades) {
        this.grades = grades;
    }
    public void printTotalGrade() {
        int totalGrade = 0;
        for (int grade : grades.values()) {
            totalGrade += grade;
        }
        System.out.println("总成绩为: " + totalGrade);
    }
    public void bootFailedGrades(){
        for (Map.Entry<String, Integer> entry : grades.entrySet()) {
            if (entry.getValue() < 60) {
                int boosted = (int) (entry.getValue() * 1.1);
                grades.put(entry.getKey(), boosted);
                System.out.println(entry.getKey() + "的成绩提升为: " + boosted);
            }
        }

    }
    public void printAverageGrade() {
        int totalGrade = 0;
        int count = 0;
        for (int grade : grades.values()) {
            totalGrade += grade;
            count++;
        }
        double averageGrade = (double) totalGrade / count;
        System.out.printf("平均成绩为: %.2f\n" ,averageGrade);
    }
}
